<template>
  <div class="app">
    <button @click="test1">获取【分类数据】</button>
    <button @click="test2">获取【头条新闻】</button>
    <button @click="test3">获取【百度新闻】</button>
  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    name:'App',
    methods: {
      test1(){
        axios.get('http://sph-h5-api.atguigu.cn/api/product/getBaseCategoryList').then(
          (res)=>{
            console.log('请求成功',res.data.data)
          },
          (err)=>{
            console.log('请求失败',err.message)
          }
        )
      },
      test2(){
        axios.get('http://localhost:8080/tt/hot-event/hot-board/?origin=toutiao_pc').then(
          (res)=>{
            console.log('请求成功',res.data.data)
          },
          (err)=>{
            console.log('请求失败',err.message)
          }
        )
      },
      test3(){
        axios.get('http://localhost:8080/bd/widget?id=LocalNews&ajax=json').then(
          (res)=>{
            console.log('请求成功',res.data.data.LocalNews.data.rows.first)
          },
          (err)=>{
            console.log('请求失败',err.message)
          }
        )
      },
    },
  }
</script>

<style>
  .app {
    background-color: #ddd;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
  }
</style>